package com.x.chalk.controller;

import com.x.chalk.config.SystemConfig;
import com.x.chalk.dto.MoodAddDto;
import com.x.chalk.service.intf.MoodService;
import com.x.chalk.vo.R;
import com.x.chalk.vo.parms.PageParams;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @author FSir
 * @create 2022-09-29 23:41
 */
@RestController
@RequestMapping("/api/mood/")
@Api("圈子相关操作")
@CrossOrigin//跨域
public class MoodController {
    @Autowired
    private MoodService moodService;

    /**
     * 添加圈子动态
     * @param info
     * @param request
     * @return
     */
    @PostMapping("add.do")
    @ApiOperation(value = "添加圈子动态")
    public R add(String info, HttpServletRequest request){
       return  moodService.add(info,request.getHeader(SystemConfig.HEADER_TOKEN));
    }

    /**
     * 分页查询所有圈子动态
     * @param pageParams
     * @return
     */
    @PostMapping("queryPage")
    @ApiOperation(value = "分页查询所有圈子动态")
    public R queryPage(@RequestBody PageParams pageParams){
        return  moodService.queryPage(pageParams);
    }
    /**
     * 查询单个动态
     */
    @GetMapping("queryOne")
    @ApiOperation(value = "查询单个动态")
    public R queryOne(int id){
        return  moodService.queryOne(id);
    }
    /**
     * 查询我的动态
     */
    @GetMapping("queryMy")
    @ApiOperation(value = "查询我的动态")
    public R queryMy(HttpServletRequest request){
        return  moodService.queryMy(request.getHeader(SystemConfig.HEADER_TOKEN));
    }

}
